package com.zzy.oss.controller;

import com.zzy.commonutils.R;
import com.zzy.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author KAZU
 * @Date 2023/1/10 16:56
 * @Version 1.0
 */
@SuppressWarnings({"all"})
@RestController
@RequestMapping("eduoss/fileoss")
@CrossOrigin
public class OssController {

	@Autowired
	private OssService ossService;
	
	/**
	 * 上传头像方法
	 * */
	@PostMapping
	public R uploadOssFile(MultipartFile file) {
		/**
		 * 获取上传文件 MultipartFile
		 * 返回上传到oss的路径
		 * */
		String url = ossService.uploadFileAvatar(file);
//		System.out.println("url: " + url);
		return R.ok().data("url", url);
	}
	
	
}
